﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Mtool.FSM;

namespace ConsoleDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //testPairwise();
            testStatemachine();

            //DataTest.TestSaveSth();
            //DataTest.TestLoadSth();

            Console.WriteLine("...Press any key to exit");
            Console.Read();
        }

        private static void testPairwise()
        {
            PictFile pi = new PictFile(@"E:\study\tools\pict\3.4.rc\release\cli\amd64fre\pict.exe",
                @"E:\study\tools\pict\3.4.rc\release\cli\amd64fre\tmp");
            for (int i = 0; i < 8; ++i)
            {
                pi.AddInput("sh"+i, 2, "a1", "a2");//, "a3", "a4");
                //pi.AddInput("sh2", 2, "c1", "c2", "c3", "c4");
                //pi.AddInput("sh3", 2, "d1", "d2", "d3", "d4");
            }
            List<PictOutputVarList> outputs = pi.RunPict();
            foreach (PictOutputVarList pov in outputs)
            {
                Console.WriteLine("combi: {0}", pov.ToString());
            }
        }

        private static void testStatemachine()
        {
            string inputFile = "mtool.sample.output.xml";
            Console.WriteLine("Read from {0}", inputFile);
            FSM myFSM = FSM.LoadFromXML(inputFile);
            Console.WriteLine("Loaded!");

            myFSM.SaveToXML("mtool.sample.saved.xml");
            Console.WriteLine("Loaded one is saved!");

            myFSM.Initialize();
            Console.WriteLine("Loaded one is initialized!");

            List<Tour> wa = myFSM.GenerateTours(myFSM.States[0], 1, 5, 3);
            Console.WriteLine("{0} tours generated!", wa.Count);
            foreach (Tour t in wa)
            {
                Console.WriteLine("Tour: {0}", t.ToString());
            }           
        }
    }
}
